home *** CD-ROM | disk | FTP | other *** search
- /*
- WGT - Win32 Games Programming Library
- Copyright (C) 2002-2004 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- wazoo AT wazooenterprises DOT com
- */
-
- #include "IniConfigReader.h"
-
- namespace peon
- {
-
- IniConfigReader::IniConfigReader(const String& strFile)
- {
- //TCHAR strOutput[MAX_PATH];
- //sprintf(strOutput, "attempting to load ini: %s\n", strFile.c_str());
- //OutputDebugString(strOutput);
- m_strFileName = strFile;
-
- }
-
- IniConfigReader::~IniConfigReader()
- {
-
- }
-
- DWORD IniConfigReader::getString(const String strSection, const String strKey, const String strDefault, String& strReturn)
- {
-
- DWORD dwResult = 0;
- TCHAR strTemp[MAX_PATH];
- ZeroMemory( &strTemp, sizeof( strTemp ) );
- dwResult = GetPrivateProfileString(strSection.c_str(),
- strKey.c_str(),
- strDefault.c_str(),
- strTemp,
- MAX_PATH,
- m_strFileName.c_str());
-
- strReturn = strTemp;
-
-
- return dwResult;
- }
-
- UINT IniConfigReader::getInt(String strSectionName, String strKeyName, int iDefault)
- {
-
- UINT iResult;
-
- iResult = GetPrivateProfileInt(strSectionName.c_str(),
- strKeyName.c_str(),
- iDefault,
- m_strFileName.c_str());
- return iResult;
- }
-
- bool IniConfigReader::getBool(const String strSection, const String strKey, const String strDefault)
- {
-
- String strTemp = "";
-
- getString(strSection, strKey, strDefault, strTemp);
-
- if(strTemp == "TRUE")
- {
- return true;
- }else
- {
- return false;
- }
-
- }
-
- float IniConfigReader::getFloat(String strSection, String strKey, String strDefault)
- {
-
- String strTemp;
-
- getString(strSection, strKey, strDefault, strTemp);
-
- return (float)strtod(strTemp.c_str(),TEXT('\0'));
-
-
- }
-
-
- }
-